package cn.fly.chatgpt.mapper;

import cn.fly.chatgpt.domain.entity.Chatgpt;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ChatgptMapper {


    @Select("select question, qus_time, answer, ans_time, chat_id, user_id from chatgpt where user_id = #{userId} and chat_id = #{chatId}")
    List<Chatgpt> getMyDialogue(@Param("userId") Integer userId, @Param("chatId") Long chatId);

    @Insert("insert into chatgpt (question, answer, qus_time, ans_time, chat_id, user_id) values (#{question}, #{answer}, #{qusTime}, #{ansTime}, #{chatId}, #{userId})")
    void addInfo(Chatgpt chatgpt);

    @Select("select chat_id from chat_user where user_id = #{userId}")
    List<Long> getChatList(Integer userId);

    @Insert("insert into chat_user (chat_id, user_id) VALUES (#{chatId}, #{userId})")
    void newChat(@Param("chatId") Long chatId, @Param("userId") Integer userId);
}
